package com.osce.ex.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csce.domain.entity.exam.ExExercise;
import com.csce.domain.entity.exam.ExQuestion;
import com.csce.domain.entity.exam.vo.ExExamQuestion;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 理论练习Mapper接口
 *
 * @author zzx
 * @since 2023-08-02
 */
@Repository
public interface ExExerciseMapper extends BaseMapper<ExExercise> {

    /**
     * 查询理论练习
     *
     * @param id 理论练习主键
     * @return 理论练习
     */
    ExExercise selectExExerciseById(Long id);

    /**
     * 查询理论练习列表
     *
     * @param exExercise 理论练习
     * @return 理论练习集合
     */
    List<ExExercise> selectExExerciseList(ExExercise exExercise);

    /**
     * 新增理论练习
     *
     * @param exExercise 理论练习
     * @return 结果
     */
    int insertExExercise(ExExercise exExercise);

    /**
     * 修改理论练习
     *
     * @param exExercise 理论练习
     * @return 结果
     */
    int updateExExercise(ExExercise exExercise);

    /**
     * 删除理论练习
     *
     * @param id 理论练习主键
     * @return 结果
     */
    int deleteExExerciseById(Long id);

    /**
     * 批量删除理论练习
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteExExerciseByIds(Long[] ids);

    int insertExExerciseQuestion(@Param("id") Long id, @Param("questionIds") Long[] questionIds);

    List<ExQuestion> selectExQuestionsById(@Param("id") Long id);

    List<Long> selectExQuestionIdsById(@Param("id") Long id);

    int updateExExerciseQuestion(ExExamQuestion examQuestion);

    void deleteExExerciseQuestionByIds(@Param("ids") Long... ids);

    @MapKey("questionId")
    Map<Long, ExExamQuestion> selectExerciseQuestions(@Param("ex_id") Long exId);
}
